package com.qk.management.controller;

import com.qk.common.Result;
import com.qk.dto.activity.ActivityDTO;
import com.qk.entity.Activity;
import com.qk.management.service.ActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/activities")
@SuppressWarnings("all")
public class ActivityController {
    @Autowired
    private ActivityService activityService;

    @GetMapping
    public Result getActivityList(ActivityDTO activityDTO) {
        return activityService.getActivityList(activityDTO);
    }
    @GetMapping("/{id}")
    public Result getActivityById(@PathVariable Integer id) {
        log.info("通过id查询:{}",id);
        return activityService.getActivityById(id);
    }
    @GetMapping("/type/{type}")
    public Result getActivityByType(@PathVariable Integer type) {
        log.info("通过类型查询:{}",type);
        return activityService.getActivityByType(type);
    }
    @PostMapping
    public Result addActivity(Activity activity) {
        log.info("新增活动:{}",activity);
        return activityService.addActivity(activity);
    }
    @DeleteMapping("/{id}")
    public Result deleteActivity(@PathVariable Integer id) {
        log.info("删除活动:{}",id);
        return activityService.deleteActivity(id);
    }
    @PutMapping
    public Result updateActivity(@RequestBody Activity activity) {
        log.info("更新活动:{}",activity);
        return activityService.updateActivity(activity);
    }

}
